﻿
CREATE FUNCTION QIC.CallFactory_FN(@Token QIC.TokenTable READONLY, @CallerId INT, @CalleeId INT, @ReturnPropertName VARCHAR(50), @TokenMap VARCHAR(50), @Indent INT, @CalleeDelegateName varchar(50))
RETURNS VARCHAR(MAX)
AS
BEGIN

	DECLARE @Call VARCHAR(MAX) 
	
	SET @Call = ''

	IF ISNULL(@ReturnPropertName,'') = ''
	BEGIN
		SET @Call += QIC.Indent(@Indent) + 'RETURN ' + QIC.ObjectName(@CalleeId) + ' (' + QIC.InterfaceTokenCall(@Token, @CalleeId, @TokenMap) + ')'
	END
	ELSE
	BEGIN
		SET @Call += QIC.Indent(@Indent) + 'SET ' + @ReturnPropertName + ' = ' + QIC.ObjectName(@CalleeId) + ' (' + QIC.InterfaceTokenCall(@Token, @CalleeId, @TokenMap) + ')'
	END

	RETURN @Call

END

